<?php
function _afmarr($keyarr,$arr){
	foreach($arr as $v){
		$arrayj[]=$v;
	}

	$i=0;
	foreach($keyarr as $val){
		$array[$val]=$arrayj[$i];
		$i++;
	}
	return $array;
}
function _ax($v,$pl=-1,$ret=""){
$pl+=1;//$pl=$print_my_left
if (is_array($v)||is_object($v) ){
    $ret=$ret.str_repeat("",$pl*4)."\n";
   foreach ($v as $key=>$val)
	{
	    $ret=$ret."    <items>";
        if (is_array($val)||is_object($val))
	    {
			$ret=_ax2($val,$pl,$ret)."    </items>\n";}
        else 
	    {$ret=$ret."    $val</items>\n";}
    }
}
else { $ret=$ret.$v;  }
   	return $ret;
}

function _ax2($v,$pl=-1,$ret=""){
$pl+=1;
if (is_array($v)||is_object($v) ){
    $ret=$ret.str_repeat("  ",$pl*4)."\n";
   foreach ($v as $key=>$val)
	{
    $ret=$ret.str_repeat("  ",$pl*4+2)."<k$pl-".$key.">";
        if (is_array($val)||is_object($val))
	    {
			$ret=_ax2($val,$pl,$ret).str_repeat("  ",$pl*4+2)."</k".$pl."-".$key.">\n";}
        else 
	    {$ret=$ret."$val</k".$pl."-".$key.">\n";}
    }
}
else 
{  $ret=$ret.$v;
}
   return $ret;
}

class sxml{
var $part1 = '<?xml version="1.0" encoding="utf-8"?>';
var $first_label = 'tables';	
var $fields = array('ch','ja','ko','en');
var $rows=array();
var $cu_rowindex=0;
var $xmlcont;
function __construct(){;}	
function add_rows($arr){
	$this->rows[$this->cu_rowindex]=_afmarr($this->fields,$arr);
	$this->cu_rowindex++;
	return $this->rows;	
}
function arrtoxml(){
	$this->xmlcont.=$this->part1;
	$this->xmlcont.="\n<root>"._ax($this->rows);
	return $this->xmlcont.'</root>';
	}
 
}
?>